import mongoose from 'mongoose';
import { formatDateByNow } from '~/utils/util.date';

export interface IUserFeedback extends mongoose.Document {
	userId: mongoose.Schema.Types.ObjectId;
	resourceId: mongoose.Schema.Types.ObjectId;
	content: string;
	createdAt?: string;
	updatedAt?: string;
}

// 用户反馈
const UserFeedbackSchema = new mongoose.Schema<IUserFeedback>(
	{
		userId: {
			type: mongoose.Schema.Types.ObjectId,
			required: true,
		},
		resourceId: {
			type: mongoose.Schema.Types.ObjectId,
			required: true,
		},
		content: {
			type: String,
		},
		createdAt: {
			type: String,
			default: formatDateByNow(),
		},
		updatedAt: {
			type: String,
			default: formatDateByNow(),
		},
	},
	{
		collection: 'user_feedback',
	}
);

export const UserFeedbackModel = mongoose.model('UserFeedback', UserFeedbackSchema);
